package day03;
//逻辑运算符的演示
public class OperDemo3 {
    public static void main(String[] args) {
        //3)逻辑运算符：&&、||、!
        int a=5,b=10,c=5;
        boolean b1 = b>=a && b<c;
        System.out.println(b1);                       //true&&false=false
        System.out.println(b<=c && b>a);              //false&&true=false
        System.out.println(a==b && c>b);              //false&&false=false
        System.out.println(b!=c && a<b);              //true&&true=true
        int age = 40;
        System.out.println(age>=18 && age <= 50);     //年龄在18到50之间
        System.out.println("-------------------");

        System.out.println(b>=a || b<c);             //true||false=true
        System.out.println(b<=c || b>a);             //false||true=true
        System.out.println(b!=c || a<b);             //true||true=true
        System.out.println(a==b || b<c);             //false||false=false
        int score = 900;
        System.out.println(score < 0 || score >100); //成绩不合法(不在0到100之间)
        System.out.println("-------------------");

        boolean b2 = !(a<b);
        System.out.println(b2);                      //!true=false
        System.out.println(!(a>b));                  //!false=true

        //演示短路：
        boolean b3 = a>b && c++>2;
        System.out.println(b3); //false
        System.out.println(c); //5. 发生短路了

        boolean b4 = a<b || c++>2;
        System.out.println(b4); //true
        System.out.println(c);  //5,发生短路了
    }
}
